import { createRouter, createWebHashHistory } from 'vue-router'

const constantRoutes = [
  {
    path: '',
    redirect: '/page-home',
  },
  {
    path: '/page-home',
    component: () => import('@/views/page-home.vue'),
  },
  {
    path: '/page-list',
    name: 'page-list',
    component: () => import('@/views/page-list.vue'),
    // 需要做前进刷新后退缓存的路由
    meta: { keepAlive: true },
  },
  {
    path: '/page-detail',
    name: 'page-detail',
    component: () => import('@/views/page-detail.vue'),
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
})

export default router

export function setupRouter(app) {
  app.use(router)
}
